package net.prasenjit.poc.httpclient;

import org.apache.http.conn.ssl.AbstractVerifier;

import javax.net.ssl.SSLException;

/**
 * Created by PPurohit on 12/24/2014.
 */
public class CustomSSLHostnameVerifier extends AbstractVerifier {

    private static final String IPV4_REGEXP = "^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$";

    @Override
    public void verify(String host, String[] cns, String[] subjectAlts) throws SSLException {
        if (host.matches(IPV4_REGEXP)) {
            return;
        }
        verify(host, cns, subjectAlts, false);
    }
}
